//////////////////////////////////////////////////////
// MYDSound.h
//////////////////////////////////////////////////////

#pragma once

#include "dsound.h"
#include <stdio.h>
#include <D3dx8tex.h>
//#include "Wave.h" 
#include "Constants.h"

class cMyDSound
{
protected:
    IDirectSound8* g_pDSObject;
	IDirectSoundBuffer8* p_TownMusic;  //global access
	DSBUFFERDESC dsbd; //buffer description
    HWND g_hWnd;
    char m_szErrorMsg[256];
	 
	IDirectSoundBuffer8* m_pMonsterDieSound;
    IDirectSoundBuffer8* m_pMonsterHitSound;
    IDirectSoundBuffer8* m_pPlayerHitSound;
    IDirectSoundBuffer8* m_pFootstepSound;
    IDirectSoundBuffer8* m_pItemOpenSound;
	IDirectSoundBuffer8* m_pWilds;
 
public:
    cMyDSound(void);
    ~cMyDSound(void);
    void SetWindowHandle(HWND hWnd);
	HRESULT InitDirectSound(void);
    char* GetErrorString(void);
    HRESULT PlaySound(int iSoundID);
	void StopSound(int);
	void Handlekeys(WPARAM);

private:
	HRESULT CreateBuffers();
	IDirectSoundBuffer8 *CreateBufferFromWAV(FILE *fp, sWaveHeader *Hdr);
	BOOL LoadSoundData(IDirectSoundBuffer8 *pDSBuffer, long LockPos, FILE *fp, long Size);
	IDirectSoundBuffer8 *LoadWAV(char *Filename);
    void CleanUp(void);

	
	
};
